@extends('admin.layout')
@section('title', '网站 - 升级列表')
@section('content')
        <!-- 面包屑导航 -->
        <div class="row wrapper border-bottom white-bg page-heading" style="height: 45px;">
            <div class="col-sm-12">
                <ol class="breadcrumb" style="padding-top: 15px;">
                    <li>
                        <a href="index_v1.html">主页</a>
                    </li>
                    <li>
                        <strong>升级列表</strong>
                    </li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>升级列表 <small></small></h5>
                        </div>
                        <div class="ibox-content" style="overflow-y: hidden;overflow-x: auto;">

                            <table class="table table-striped table-bordered table-hover dataTables-example">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>会员等级标题</th>
                                        <th>升级所需积分</th>
                                        <th>唯一标识</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    @foreach ($data as $key=>$item)
                                    <tr class="gradeX">
                                        <td>{{$key+1}}</td>
                                        <td>{{$item->name}}</td>
                                        <td>{{$item->exp}}</td>
                                        <td class="center">{{$item->sign}}</td>
                                        <td>
                                        {{-- <a class="btn btn-primary btn-sm" onclick="lvedit(this)" title="{{$item->id}}">编辑</a> --}}
                                            <a class="btn btn-primary btn-sm" onclick="delRow(this)" title="{{$item->id}}">删除</a>
                                        </td>
                                    </tr>
                                    @endforeach
                                   
                            

                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div>

        </div>

        <!-- Page-Level Scripts -->
        <script>
            $(document).ready(function () {
                $('.dataTables-example').dataTable();

                /* Init DataTables */
                var oTable = $('#editable').dataTable();

            });

            //编辑
            function lvedit(val){
                //iframe层
                layer.open({
                type: 2,
                title: '用户编辑',
                shadeClose: true,
                shade: 0.8,
                area: ['80%', '80%'],
                content: '/admin/lvedit.html' //iframe的url
                }); 
            }

            //删除
            function delRow(id){
                //询问框
                layer.confirm('确定要删除该条数据码？', {title:'提示',btn: ['删除','取消']}, function(){
                    layer.msg('删除', {time: 1500});
                    var fd = new FormData();
                    fd.append('id',id.title);
                    $.ajax({
                        url: 'lvdel',
                        type: 'POST',
                        timeout: 3000,
                        dataType: 'JSON',
                        contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                        data: fd,
                        contentType: false,//不设置内容类型
                        processData: false,//不处理数据
                        success: function (data) {
                            if (data.code == 200) {
                                layer.msg(data.msg, {
                                    // icon: 1,
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                    }, function(){
                                        location.reload();
                                });   
                            } else {
                                toastr.warning(data.msg);
                            }
                        },
                        error: function (XMLResponse) {
                            //异常捕获
                            toastr.error(XMLResponse.responseText);
                        }
                    });
                }, function(){});
            }

        </script>
@endsection